#ifndef BSONEXPLORERMODEL_H
#define BSONEXPLORERMODEL_H

#include <QAbstractTableModel>
#include <QObject>
#include <QModelIndex>
#include <QVariant>
#include <QVector>
#include <QMap>

#include <client/dbclient.h>
using namespace mongo;
#include <vector>
#include <string>
#include <map>
using namespace std;
class BsonModelData
{
public:
    QString fieldName;
    QVariant fieldValue;
    QString fieldType;
    BSONElement field;
};
class BsonExplorerModel : public QAbstractTableModel
{
    Q_OBJECT
public:
    BsonExplorerModel(QObject *parent = 0);
    int rowCount(const QModelIndex &parent) const;
    int columnCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;
public:
    void setBSONObject(BSONObj& obj);
    void initBSONObject(BSONObj& obj);
    static QString getBSONObjTypeName(mongo::BSONType type);
    static QVariant getDataFromBSONElement(BSONElement bsonElement);
protected:
    QVector<BsonModelData> allBSONElementsVector;
    //BSONObj bsonObj;
    //vector<BSONElement> allBSONElements;
    //QVector<BSONElement> allBSONElementsVector;
    //vector<string> allBSONElementsFieldName;
    //vector<QVariant> allBSONElementsValue;
    //static QMap<mongo::BSONType,QString> allBSONElementsType;
};

#endif // BSONEXPLORERMODEL_H
